﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TVGuide.DataAccess.Common
{
    class HProgram
    {
        #region Public Properties

        public short? CategoryId { get; set; }
        public int ChannelId { get; set; }
        public short? CountryId { get; set; }
        public String Description { get; set; }
        public short LanguageId { get; set; }
        public String Name { get; set; }
        public DateTime Time { get; set; }
        public DateTime HisDate { get; set; }

        #endregion

        public HProgram() { }

        #region Explicit Cast

        public static explicit operator hprogram(HProgram p)
        {
            if (p == null)
                return null;
            hprogram prog = new hprogram();
            prog.categoryID = p.CategoryId;
            prog.channelID = p.ChannelId;
            prog.countryID = p.CountryId;
            prog.description = p.Description;
            prog.languageID = p.LanguageId;
            prog.title = p.Name;
            prog.date = p.Time;
            prog.hisDate = p.HisDate;
            return prog;
        }

        public static explicit operator HProgram(hprogram p)
        {
            if (p == null)
                return null;
            HProgram prog = new HProgram();
            prog.CategoryId = p.categoryID;
            prog.ChannelId = p.channelID;
            prog.CountryId = p.countryID;
            prog.Description = p.description;
            prog.LanguageId = p.languageID;
            prog.Name = p.title;
            prog.Time = p.date;
            prog.HisDate = p.hisDate;
            return prog;
        }

        public static explicit operator HProgram(program p)
        {
            if (p == null)
                return null;
            HProgram prog = new HProgram();
            prog.CategoryId = p.categoryID;
            prog.ChannelId = p.channelID;
            prog.CountryId = p.countryID;
            prog.Description = p.description;
            prog.LanguageId = p.languageID;
            prog.Name = p.title;
            prog.Time = p.date;
            prog.HisDate = DateTime.Now;
            return prog;
        }

        public static explicit operator Program(HProgram p)
        {
            if (p == null)
                return null;

            Program prog = new Program();
            prog.CategoryId = p.CategoryId;
            prog.ChannelId = p.ChannelId;
            prog.CountryId = p.CountryId;
            prog.Description = p.Description;
            prog.LanguageId = p.LanguageId;
            prog.Name = p.Name;
            prog.Date = p.Time;
            return prog;
        }

        #endregion
    }
}
